package com.niit.service;

import com.niit.model.*;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author： 曾渝晋
 * @date: 2021/6/16 1:14 上午
 * @description:
 *  写相关服务降级的方法
 * @modified:
 * @Version: 1.0
 */
@Component
public class AdminFallbackFactory implements FallbackFactory<AdminService> {

    @Override
    public AdminService create(Throwable throwable) {
        return new AdminService() {
            @Override
            public List<Admin> adminlist() {
                //查不到admin列表，展示在网页上的东西
                Admin admin1 = new Admin();
                admin1.setName("服务降级");
                List<Admin> admins = new ArrayList<>();
                admins.add(admin1);
                return admins;
            }

            @Override
            public List<Student> studentlist( ) {
               Student s=new Student();
               s.setName("服务降级");
               List<Student> s2=new ArrayList<>();
               s2.add(s);
               return s2;
            }

            @Override
            public List<Teacher>  teacherlist() {
                 Teacher t=new Teacher();
                 t.setName("服务降级");
                 List<Teacher> t2=new ArrayList<>();
                 t2.add(t);
                 return t2;
            }

            @Override
            public List<Classes> classlist() {
                 Classes c=new Classes();
                 c.setClass_name("服务降级");
                 List<Classes> c2=new ArrayList<>();
                 c2.add(c);
                 return c2;
            }

            @Override
            public List<Question> questionslist() {
                Question q=new Question();
                q.setQuestion_face("服务降级");
                List<Question> q2=new ArrayList<>();
                q2.add(q);
                return q2;
            }

            @Override
            public List<ExamPaper> exampaperslist() {
                 ExamPaper e=new ExamPaper();
                 e.setId_class(250);
                 List<ExamPaper> ew=new ArrayList<>();
                 ew.add(e);
                 return ew;
            }

            @Override
            public Admin getadminById(Long id) {
                Admin admin1=new Admin();
                admin1.setName("服务降级");
                return admin1;
            }

            @Override
            public Student getstudentById(Long id) {
                Student student1=new Student();
                student1.setName("服务降级");
                return student1;
            }

            @Override
            public Teacher getteacherById(Long id) {
                 Teacher t1=new Teacher();
                 t1.setName("服务降级");
                 return t1;
            }

            @Override
            public Classes getclassById(Long id) {
                 Classes c1=new Classes();
                 c1.setClass_name("服务降级");
                 return c1;
            }

            @Override
            public Question getquestionById(Long id) {
                Question q1=new Question();
                q1.setQuestion_face("服务降级");
                return q1;
            }

            @Override
            public ExamPaper getExamPaperById(Long id) {
                 ExamPaper e1=new ExamPaper();
                 e1.setPaper_name("服务降级");
                 return  e1;
            }

            @Override
            public String add(Admin admin) {
                return "服务降级";
            }

            @Override
            public String add(Student student) {
                return "服务降级";
            }

            @Override
            public String add(Teacher teacher) {
                return "服务降级";
            }

            @Override
            public String add(Classes classes) {
                return "服务降级";
            }

            @Override
            public String add(Question question) {
                return "服务降级";
            }

            @Override
            public String add(ExamPaper examPaper) {
                return "服务降级";
            }

            @Override
            public String updateadmin(Long id) {
                return "服务降级";
            }

            @Override
            public String updateteacher(Long id) {
                return "服务降级";
            }

            @Override
            public String updatestudent(Long id) {
                return "服务降级";
            }

            @Override
            public String updateclass(Long id) {
                return "服务降级";
            }

            @Override
            public String updatequestion(Long id) {
                return "服务降级";
            }

            @Override
            public String updateexampaper(Long id) {
                return "服务降级";
            }

            @Override
            public String updatestatus(Long id) {
                return "服务降级";
            }

            @Override
            public String deleteAdminById(Long id) {
                return "服务降级";
            }

            @Override
            public String deleteStudentById(Long id) {
                return "服务降级";
            }

            @Override
            public String deleteTeacherById(Long id) {
                return "服务降级";
            }

            @Override
            public String deleteClassById(Long id) {
                return "服务降级";
            }

            @Override
            public String deleteQuestionById(Long id) {
                return "服务降级";
            }

            @Override
            public String deleteExamPaperById(Long id) {
                return "服务降级";
            }
        };
    }
}
